package o;

import android.content.Context;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.StrikethroughSpan;
import android.widget.TextView;
import com.huawei.appgallery.foundation.application.pkgmanage.model.update.ApkUpgradeInfo;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import java.util.Locale;
import o.ewm.n;

public class drs extends dkd {
    public drs(Context context) {
        super(context);
    }

    private static CharSequence ˊ(Context context, int i, String str, String str2) {
        StringBuilder stringBuilder = new StringBuilder();
        if (!TextUtils.isEmpty(str)) {
            stringBuilder.append(str);
        }
        if (!TextUtils.isEmpty(str2)) {
            stringBuilder.append(' ');
            stringBuilder.append(str2);
        }
        Object toUpperCase = context.getResources().getString(i, new Object[]{stringBuilder.toString()}).toUpperCase(Locale.ENGLISH);
        String toUpperCase2 = str.toUpperCase(Locale.ENGLISH);
        CharSequence spannableString = new SpannableString(toUpperCase);
        if (!(TextUtils.isEmpty(str2) || TextUtils.isEmpty(toUpperCase2))) {
            int lastIndexOf = toUpperCase.lastIndexOf(toUpperCase2);
            if (lastIndexOf > -1) {
                spannableString.setSpan(new StrikethroughSpan(), lastIndexOf, toUpperCase2.length() + lastIndexOf, 33);
            }
        }
        return spannableString;
    }

    public ckd ˋ() {
        return new dry();
    }

    public ckd ˎ(int i, int i2) {
        return new dry(this.ˋ, i, i2);
    }

    public CharSequence ˋ(BaseDistCardBean baseDistCardBean, cke o_cke, CharSequence charSequence, TextView textView) {
        CharSequence ˋ = super.ˋ(baseDistCardBean, o_cke, charSequence, textView);
        if (o_cke == cke.RESERVE_DOWNLOAD_APP) {
            return NetWorkUtil.getWifiResId(this.ˋ, n.ʽﾞ).toString().toUpperCase(Locale.getDefault());
        }
        if ((o_cke == cke.DOWNLOAD_APP || o_cke == cke.UPGRADE_APP || o_cke == cke.SMART_UPGRADE_APP || o_cke == cke.OPEN_APP) && baseDistCardBean.ᐝॱ() && !ebz.ॱ().ˎ(baseDistCardBean.ॱـ())) {
            if (TextUtils.isEmpty(baseDistCardBean.ॱˋ())) {
                ˋ = this.ˋ.getString(n.ˮॱ);
            } else {
                ˋ = baseDistCardBean.ॱˋ();
            }
            return ˋ.toString().toUpperCase(Locale.getDefault());
        } else if (o_cke == cke.DOWNLOAD_APP || o_cke == cke.UPGRADE_APP) {
            return ˏ(baseDistCardBean, o_cke, textView);
        } else {
            if (o_cke == cke.SMART_UPGRADE_APP) {
                return ˋ(baseDistCardBean, ˋ);
            }
            return ˋ;
        }
    }

    private CharSequence ˋ(BaseDistCardBean baseDistCardBean, CharSequence charSequence) {
        ApkUpgradeInfo ॱ = dug.ॱ(baseDistCardBean.ॱـ());
        if (ॱ == null) {
            return charSequence;
        }
        int i = n.ﾟॱ;
        Object ॱ2 = ॱ(baseDistCardBean);
        Object obj = "";
        if (ॱ.ʼ() > 0) {
            obj = epw.ˊ(ॱ.ʼ());
        } else {
            i = n.ﹺ;
        }
        if (!TextUtils.isEmpty(ॱ2) || !TextUtils.isEmpty(obj)) {
            return ˊ(this.ˋ, i, ॱ2, obj);
        }
        return this.ˋ.getResources().getString(n.ﹶ).toString().toUpperCase(Locale.getDefault());
    }

    private CharSequence ˏ(BaseDistCardBean baseDistCardBean, cke o_cke, TextView textView) {
        CharSequence ॱ = ॱ(baseDistCardBean);
        int i = o_cke == cke.UPGRADE_APP ? TextUtils.isEmpty(ॱ) ? n.ﹶ : n.ﹺ : TextUtils.isEmpty(ॱ) ? n.ٴ : n.ـॱ;
        if (TextUtils.isEmpty(ॱ)) {
            return this.ˋ.getResources().getString(i).toString().toUpperCase(Locale.getDefault());
        }
        return ˊ(this.ˋ, i, ॱ, null);
    }

    private String ॱ(BaseDistCardBean baseDistCardBean) {
        String str = "";
        if (baseDistCardBean.ॱᶥ() == 1 && cep.ˏ() && baseDistCardBean.ᐝˋ() > 0) {
            return epw.ˊ(baseDistCardBean.ᐝˋ());
        }
        if (baseDistCardBean.ˉ() > 0) {
            return epw.ˊ(baseDistCardBean.ˉ());
        }
        return str;
    }
}
